package com.eyedsion.his.web.service.sycndata;

import com.alibaba.fastjson.JSON;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.lang.reflect.ParameterizedType;
import java.util.List;

/**
 * @author 彭长云
 * @Description:cxf调用webservice
 * @date 2019/1/7 16:19
 */
@Component
public class WebServiceClient {

    @Value("${syncdata.webservice.wsdlurl}")
    private String wsdlUrl;

    public Object client(String methodName, Object params) {
        // 创建动态客户端
        JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
        Client client = dcf.createClient(wsdlUrl);

        Object[] objects = new Object[0];
        try {
            objects = client.invoke(methodName, params);
        } catch (java.lang.Exception e) {
            e.printStackTrace();
        }
        return objects[0];
    }
}
